<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- 地区选择 -->
<script type="text/javascript">
$(document).ready(function () {
	//省份/城市选择
    $("#province").change(function(){
		var province = $("#province").val();
		selectCities(province);
    });
});
/**
 * 市
 */
function selectCities(province, city){
	if(!province || province == '') {return;}
	$.dpAjax({
		show:false,
 		url:'${basePath}/YwBusinessCarAreaPriceController/selectCities',
			data:{provinceId:province},
			success: function(datas){
 			  if(datas.flag == "100100")
				  {
 				  var data = datas.result;
 				 var html = "";
 				var firstFlag = true;
 				  for(var i in data) {
 					  if(firstFlag && !city) {
 						firstFlag = false;
 				  		html += "<option value='" +i+ "' selected>" + data[i]+ "</option>";
 					  } else if(city && city == i){
 						 html += "<option value='" +i+ "' selected>" + data[i]+ "</option>";
 					  } else {
 						 html += "<option value='" +i+ "'>" + data[i]+ "</option>";
 					  }
 				  }
 				 $("#city").html(html);
					  return;
				  }
				  if(datas.flag == "100200")
               {
					  $.fn.showDatas({"datas":datas});
             	  return;
               }
				  layer.msg(datas.message, {icon: 2});
         }
 	});
}
/**
 * 省
 */
function selectProvinces(province,callback){
	$.dpAjax({
		show:false,
 		url:'${basePath}/YwBusinessCarAreaPriceController/selectProvinces',
		data:{},
		success: function(datas){
				var data = datas.result;
				var html = "";
				var firstFlag = true;
				  for(var i in data) {
					  if(firstFlag &&　!province) {
						firstFlag = false;
				  		html += "<option value='" +i+ "' selected>" + data[i]+ "</option>";
					  } else if(province && province == i){
						 html += "<option value='" +i+ "' selected>" + data[i]+ "</option>";
					  } else {
						 html += "<option value='" +i+ "'>" + data[i]+ "</option>";
					  }
				  }
				 $("#province").html(html);
				 if(callback){
					 callback();
				 }
        }
	});
}
</script>